package com.mock.action.contact;

import com.mock.dao.BestContactMethodDao;
import com.mock.dao.ContactDao;
import com.mock.dao.ContactTypeDao;
import com.mock.dao.impl.BestContactMethodDaoImpl;
import com.mock.dao.impl.ContactDaoImpl;
import com.mock.dao.impl.ContactTypeDaoImpl;
import com.mock.model.Contact;
import com.opensymphony.xwork2.ActionSupport;

public class AddContactAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String firstnameField;
	private String surnameField;
	private String knownAsField;
	private String officePhoneField;
	private String mobilePhoneField;
	private String stHomePhoneField;
	private String emailAddressField;
	private long managerNameField;
	private String managerNameFieldFake;
	private long contactType;
	private long bestContactMethod;
	private String jobRoleField;
	private String workbaseField;
	private String jobTitleField;
	private String check;
	
	private ContactDao contactDao = new ContactDaoImpl();
	private ContactTypeDao contactTypeDao = new ContactTypeDaoImpl();
	private BestContactMethodDao bestContactMethodDao = new BestContactMethodDaoImpl();
	
	@Override
	public String execute() throws Exception {
		System.out.println(knownAsField);				
		boolean active = false;
		if ("on".equalsIgnoreCase(check)) {
			active = true;
		}
		Contact contact = new Contact(firstnameField, surnameField, knownAsField, officePhoneField, mobilePhoneField, stHomePhoneField, emailAddressField, 1, contactTypeDao.getContactTypeById(contactType), bestContactMethodDao.getBestContactMethodById(bestContactMethod), jobRoleField, workbaseField, jobTitleField, active);
		contactDao.add(contact);
		
		return SUCCESS;
	}

	public String getFirstnameField() {
		return firstnameField;
	}

	public void setFirstnameField(String firstnameField) {
		this.firstnameField = firstnameField;
	}

	public String getSurnameField() {
		return surnameField;
	}

	public void setSurnameField(String surnameField) {
		this.surnameField = surnameField;
	}

	public String getKnownAsField() {
		return knownAsField;
	}

	public void setKnownAsField(String knownAsField) {
		this.knownAsField = knownAsField;
	}

	public String getOfficePhoneField() {
		return officePhoneField;
	}

	public void setOfficePhoneField(String officePhoneField) {
		this.officePhoneField = officePhoneField;
	}

	public String getMobilePhoneField() {
		return mobilePhoneField;
	}

	public void setMobilePhoneField(String mobilePhoneField) {
		this.mobilePhoneField = mobilePhoneField;
	}

	public String getStHomePhoneField() {
		return stHomePhoneField;
	}

	public void setStHomePhoneField(String stHomePhoneField) {
		this.stHomePhoneField = stHomePhoneField;
	}

	public String getEmailAddressField() {
		return emailAddressField;
	}

	public void setEmailAddressField(String emailAddressField) {
		this.emailAddressField = emailAddressField;
	}

	public long getManagerNameField() {
		return managerNameField;
	}

	public void setManagerNameField(long managerNameField) {
		this.managerNameField = managerNameField;
	}

	public String getManagerNameFieldFake() {
		return managerNameFieldFake;
	}

	public void setManagerNameFieldFake(String managerNameFieldFake) {
		this.managerNameFieldFake = managerNameFieldFake;
	}

	public long getContactType() {
		return contactType;
	}

	public void setContactType(long contactType) {
		this.contactType = contactType;
	}

	public long getBestContactMethod() {
		return bestContactMethod;
	}

	public void setBestContactMethod(long bestContactMethod) {
		this.bestContactMethod = bestContactMethod;
	}

	public String getJobRoleField() {
		return jobRoleField;
	}

	public void setJobRoleField(String jobRoleField) {
		this.jobRoleField = jobRoleField;
	}

	public String getWorkbaseField() {
		return workbaseField;
	}

	public void setWorkbaseField(String workbaseField) {
		this.workbaseField = workbaseField;
	}

	public String getJobTitleField() {
		return jobTitleField;
	}

	public void setJobTitleField(String jobTitleField) {
		this.jobTitleField = jobTitleField;
	}

	public String getCheck() {
		return check;
	}

	public void setCheck(String check) {
		this.check = check;
	}
	
}
